package com.stadium.common.enums;

public enum MethodEnum {

    保存("1", "save"),

    修改("2", "update"),

    删除("3", "delete"),

    批量保存("4", "saveBatch"),

    批量删除("5", "deleteBatch"),

    UNKNOWN("0", "未知");
    private String code;
    private String name;

    MethodEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static MethodEnum getMethodByCode(Integer code) {
        for (MethodEnum methodEnum : MethodEnum.values()) {
            if (code.equals(methodEnum.getCode())) {
                return methodEnum;
            }
        }
        return MethodEnum.UNKNOWN;
    }

    public static MethodEnum getMethodByName(String name) {
        for (MethodEnum methodEnum : MethodEnum.values()) {
            if (name.equals(methodEnum.getName())) {
                return methodEnum;
            }
        }
        return MethodEnum.UNKNOWN;
    }
}
